<?php
include LIB_PATH . '/YAction.class.php';
class AboutAction extends YAction {
	public function __construct() {
		parent::__construct();
		
		// 登录检测
		if(!$this->isLogin()) {
			echo '_error Access Timeout'; exit;
		}
	}
	
	public function index() {
		$data = D('About')->getListByPage();
		$pageString = $data['pageString'];
		unset($data['pageString']);
		$this->assign('data', $data);
		$this->assign('pageString', $pageString);
	
		$this->display();
	}
	
	// 添加
	public function addAbout() {
		$this->display();
	}
	public function doAddAbout() {
		$data = array();
		$data['content'] = y_stripslashes($_POST['content']);
		
		if(empty($data['content'])) {
			$this->error('数据不完整');
			exit;
		}
		
		$data['posttime'] = time();
		
		D('About')->addOne($data);
		
		$this->success('添加成功');
	}
	
	// 删除
	public function delAbout() {
		$id = y_getParam('id', 'get');
		if(!is_numeric($id)) {die('param error');}
		
		D('About')->deleteOne('id='.$id);
		
		$this->success('删除成功');
	}
}